<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script>
			//改div
			function changeA(){
				//document.getElementsByTagName("a");
				let ar=document.querySelectorAll("div a");
				for (var i = 0; i < ar.length; i++) {
					ar[i].target="_blank";
				}
			}
		</script>
	</head>
	<body>
		<a href="https://www.w3school.com.cn/jsref/index.asp">baidu</a>
		<div>
			<a href="https://www.w3school.com.cn/jsref/index.asp">淘宝</a>
			<a href="https://www.w3school.com.cn/jsref/index.asp">jd</a>
			<a href="https://www.w3school.com.cn/jsref/index.asp">蘑菇街</a>
		</div>
		<input type="button" value="修改target" onclick="changeA()"/>
	</body>
</html>